home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / LhADir / REXX / LhADir.dopus
Text File  |  1996-02-03  |  22KB  |  823 lines

  1. /*
  2.   $VER: LhADir.dopus 1.12 (3.2.96)
  3.   Copyright © 1993-1996 by Edmund Vermeulen.
  4.   Placed in the public domain. No restrictions on distribution or usage.
  5.  
  6.   LhADir.dopus is an ARexx script for Directory Opus that allows you to show
  7.   the contents of LhA archives in a DOpus window and operate on the files and
  8.   directories inside the archive as if it is a normal directory.
  9. */
  10.  
  11. signal on syntax    /* intercept syntax errors */
  12. options results        /* need results */
  13. options failat 21    /* external commands are allowed return code 20 */
  14. lf='0a'x        /* ascii code for linefeed */
  15.  
  16. parse arg command portname . '"' selected '"'
  17. upper command
  18. if portname~=='' then
  19.    address value portname
  20. else
  21.    portname=address()
  22. parse var portname '.' port  /* port number */
  23.  
  24. busy on            /* busy mouse pointer on */
  25. status 3        /* get active window */
  26. win=result
  27. status 9 win        /* get number of selected entries */
  28. entries=result
  29. checkabort        /* reset abort flag */
  30.  
  31. if ~show('l','rexxsupport.library') then
  32.    call addlib('rexxsupport.library',0,-30)  /* needed for delay() and showlist() */
  33.  
  34. call checkconfig
  35. call checklhadir(win)
  36.  
  37. if selected~=='' then do
  38.    filetype=-1
  39.    entries=1
  40.    end
  41. else
  42.    if entries>0 then
  43.       call getnextone
  44.  
  45. topline=""
  46. listlha=0
  47. notmove=command~='MOVE'
  48.  
  49. select
  50.    when command='GETDIR' then
  51.       call dogetdir
  52.    when command='BROWSE' then
  53.       call dogetdir
  54.    when command='PARENT' then
  55.       call doparent
  56.    when command='ROOT' then
  57.       call doroot
  58.    when command='DELETE' then
  59.       call dodelete
  60.    when command='COPY' then
  61.       call docopy
  62.    when command='MOVE' then
  63.       call docopy
  64.    when command='MAKEDIR' then
  65.       call domakedir
  66.    when command='GETSIZES' then
  67.       call dogetsizes
  68.    otherwise do
  69.       async=pos('|'command'|','|READ|ANSIREAD|HEXREAD|')>0
  70.       if entries=0|async|pos('|'command'|','|VERSION|CFX|')>0 then
  71.          n=1
  72.       else
  73.          n=entries
  74.       thisfile=''
  75.       internal=1
  76.  
  77.       do until n=0
  78.          n=n-1
  79.          if lhadir&entries>0 then do
  80.             if filetype>0 then
  81.                call quitit("Error, directories cannot be viewed.")
  82.             address command 'LhA e -q -x2 -Qo "'patch(lhafile,0)'" T: "'patch(lhasubdir||selected,1)'"'
  83.             if rc>0 then
  84.                call quitit("Error while extracting file.")
  85.             thisfile='"T:'selected'"'
  86.             end
  87.  
  88.          select  /* internal commands */
  89.             when command='READ' then
  90.                read thisfile
  91.             when command='ANSIREAD' then
  92.                ansiread thisfile
  93.             when command='HEXREAD' then
  94.                hexread thisfile
  95.             when command='SHOW' then
  96.                show thisfile
  97.             when command='PLAY' then
  98.                play thisfile
  99.             when command='LOOPPLAY' then
  100.                loopplay thisfile
  101.             when command='PRINT' then
  102.                print thisfile
  103.             when command='ICONINFO' then
  104.                iconinfo thisfile
  105.             when command='RUN' then
  106.                run thisfile
  107.             otherwise do  /* external commands */
  108.                internal=0
  109.                if ~lhadir&entries>0 then
  110.                   thisfile='"'winpath||selected'"'
  111.                query screenname
  112.                if result=0 then
  113.                   screenname=portname  /* for compatibility */
  114.                else
  115.                   screenname=result
  116.  
  117.                select
  118.                   when command='VERSION' then
  119.                      call doversion
  120.                   when command='UNDMS' then
  121.                      call doundms
  122.                   when command='CFX' then
  123.                      call docfx
  124.                   when command='MULTIVIEW' then
  125.                      address command 'MultiView' thisfile 'PUBSCREEN' screenname 'FONTNAME' fontname 'FONTSIZE' fontsize
  126.                   when command='AMIGAGUIDE' then
  127.                      address command 'AmigaGuide' thisfile 'PUBSCREEN' screenname
  128.                   when command='VIEWTEK' then
  129.                      address command 'VT >NIL:' thisfile
  130.                   when command='RETINADISPLAY' then
  131.                      address command 'Work:RetinaTools/RetinaDisplay' thisfile
  132.                   when command='FASTVIEW' then
  133.                      address command 'Work:OtherTools/FastView >NIL:' thisfile 'DITHER'
  134.                   otherwise
  135.                      call quitit("Error, LhADir.dopus does not support the command '"command"'.")
  136.                   end
  137.                abort=0
  138.                end
  139.             end
  140.  
  141.          if internal then
  142.             abort=result~=0
  143.          busy on
  144.          if lhadir&entries>0 then do
  145.             if async then
  146.                call delay(75)  /* wait a bit before deleting */
  147.             delete '"T:'selected'"'
  148.             busy on
  149.             end
  150.          else
  151.             if internal then
  152.                n=0
  153.          if thisfile~=='' then do
  154.             selectfile '"'selected'" 0 1'  /* deselect item */
  155.             if topline=="" then
  156.                topline="OK"
  157.             end
  158.          checkabort
  159.          if result|abort then
  160.             call quitit("Aborted...")
  161.          if n>0 then
  162.             call getnextone
  163.          end
  164.       end
  165.    end
  166.  
  167. call quitit(topline)  /* finished */
  168.  
  169.  
  170. dogetdir:
  171.  
  172.    if entries>0 then
  173.       if filetype>0 then  /* list a new dir */
  174.          if lhadir then
  175.             lhasubdir=lhasubdir||selected'/'
  176.          else
  177.             winpath=winpath||selected'/'
  178.       else do  /* list an archive file */
  179.          if pos('|'upper(right(selected,4)'|'),'|.LHA|.LZH|.RUN|')=0 then
  180.             call quitit("Error, LhADir.dopus can only list LhA archives.")
  181.          if lhadir then do
  182.             request "This is an archive in an archive."lf"Extract it to 'T:' and then list it?"
  183.             uset=result
  184.             if uset then
  185.                destpath='T:'
  186.             else do
  187.                busy on
  188.                status 13 1-win  /* get window path */
  189.                destpath=result
  190.                if result=='' then
  191.                   call quitit("Aborted...")
  192.                request "Use the current destination window"lf"'"destpath"' instead?"
  193.                if ~result then
  194.                   call quitit("Aborted...")
  195.                end
  196.             busy on
  197.             toptext "Extracting from archive..."
  198.             address command 'LhA e -q -x2 -a -C0 -Qo "'patch(lhafile,0)'" "'destpath'" "'patch(lhasubdir||selected,1)'"'
  199.             if rc>0 then
  200.                call quitit("Error while extracting from archive.")
  201.             if ~uset&command='GETDIR' then
  202.                rescan 1-win
  203.             lhafile=destpath||selected
  204.             end
  205.          else
  206.             lhafile=winpath||selected
  207.          lhadir=1
  208.          lhasubdir=''
  209.          listlha=1
  210.          end
  211.    else  /* rescan current dir */
  212.       if lhadir then do
  213.          status 6 win  /* get number of entries */
  214.          listlha=result>0
  215.          end
  216.  
  217.    if command='BROWSE' then do
  218.       selectfile '"'selected'" 0 1'
  219.       call swapactive
  220.       end
  221.    if lhadir then do
  222.       call showlhadir
  223.       topline="OK"
  224.       end
  225.    else
  226.       status 13 win set '"'winpath'"'
  227.    return
  228.  
  229.  
  230. doparent:
  231.  
  232.    if lhadir&lhasubdir~=='' then do
  233.       cuthere=lastpos('/',left(lhasubdir,length(lhasubdir)-1))
  234.       lhasubdir=left(lhasubdir,cuthere)
  235.       call showlhadir
  236.       topline="OK"
  237.       end
  238.    else
  239.       parent
  240.    return
  241.  
  242.  
  243. doroot:
  244.  
  245.    if lhadir&lhasubdir~=='' then do
  246.       lhasubdir=''
  247.       call showlhadir
  248.       topline="OK"
  249.       end
  250.    else
  251.       root
  252.    return
  253.  
  254.  
  255. dodelete:
  256.  
  257.    if lhadir then do
  258.       if entries=0 then
  259.          call quitit
  260.       if notmove then do
  261.          if askdelete then do
  262.             status 26 set 'Delete'
  263.             request "Do you really wish to delete selected entries"lf"from archive?"
  264.             if ~result then
  265.                call quitit("Aborted...")
  266.             busy on
  267.             end
  268.          call getall
  269.          end
  270.       call open('actionfile','T:actionfile'port,'w')
  271.       do i=1 to entries
  272.          if type.i>0 then
  273.             wild='/#?'
  274.          else
  275.             wild=''
  276.          call writeln('actionfile','"'patch(lhasubdir||name.i,1)||wild'"')
  277.          removefile '"'name.i'" 0'
  278.          end
  279.       call close('actionfile')
  280.       toptext "Deleting from archive..."
  281.       address command 'LhA d -q -Qp -Qo "'patch(lhafile,0)'" @T:actionfile'port
  282.       if rc>0 then do
  283.          topline="Error while deleting from archive."
  284.          listlha=1
  285.          call showlhadir
  286.          end
  287.       else do
  288.          topline="OK"
  289.          displaydir
  290.          end
  291.       delete 'T:actionfile'port
  292.       delete 'T:LhADir.list'port  /* archive contents has changed */
  293.       busy on
  294.       end
  295.    else do
  296.       if notmove then
  297.          restore
  298.       delete
  299.       end
  300.    return
  301.  
  302.  
  303. docopy:
  304.  
  305.    if entries=0 then
  306.       call quitit
  307.    problem=0
  308.    src=winpath
  309.    s_lhadir=lhadir
  310.    s_lhafile=lhafile
  311.    s_lhasubdir=lhasubdir
  312.    call checklhadir(1-win)
  313.  
  314.    if s_lhadir then do
  315.       if winpath=='' then do
  316.          errortext="No destination directory selected!"
  317.          toptext errortext
  318.          notify errortext
  319.          call quitit
  320.          end
  321.       if lhadir then
  322.          winpath='T:LhADir'port'/'lhasubdir
  323.       call getall
  324.       call lhaextract
  325.       if lhadir then do
  326.          src=winpath
  327.          call lhaadd
  328.          end
  329.       else
  330.          if problem then
  331.             rescan 1-win
  332.          else do
  333.             do i=1 to entries
  334.                fileinfo '"'name.i'"' '1c'x
  335.                info.i=result
  336.                end
  337.             call swapactive
  338.             do i=1 to entries
  339.                parse var info.i name '1c'x size '1c'x '1c'x type '1c'x '1c'x days '1c'x seconds '1c'x comment '1c'x atts '1c'x
  340.                if type>0 then
  341.                   size=0
  342.                addfile '"'name'"' size type seconds+days*86400 '"'comment'"' atts '0 0'
  343.                end
  344.             displaydir
  345.             call swapactive
  346.             end
  347.       end
  348.    else
  349.       if lhadir then do
  350.          if ~notmove then do
  351.             cuthere=lastpos('/',lhafile)
  352.             if cuthere=0 then
  353.                cuthere=pos(':',lhafile)
  354.             name=substr(lhafile,cuthere+1)
  355.             if left(lhafile,length(src))==src then do
  356.                name=substr(lhafile,length(src)+1)
  357.                parse var name name '/'
  358.                fileinfo '"'name'"' '1c'x
  359.                parse var result '1c'x '1c'x '1c'x '1c'x sel '1c'x
  360.                if sel then do
  361.                   errortext="You can't move an archive into itself!"
  362.                   toptext errortext
  363.                   notify errortext
  364.                   call quitit
  365.                   end
  366.                end
  367.             end
  368.          call getall
  369.          call lhaadd
  370.          end
  371.       else do  /* normal copy or move */
  372.          restore
  373.          if notmove then
  374.             copy
  375.          else
  376.             move
  377.          end
  378.  
  379.    if (s_lhadir|lhadir)&~notmove&~problem then do
  380.       lhadir=s_lhadir
  381.       lhafile=s_lhafile
  382.       lhasubdir=s_lhasubdir
  383.       checkabort
  384.       if result then
  385.          call quitit("Aborted...")
  386.       call dodelete
  387.       end
  388.    return
  389.  
  390.  
  391. domakedir:
  392.  
  393.    getstring '"Enter directory name or archive name.lha"'
  394.    dirtomake=result
  395.    if rc|dirtomake=='' then
  396.       call quitit
  397.    now=date('i')*86400+time('s')
  398.    if lhadir then do  /* create empty dir in archive */
  399.       call createdirs(dirtomake'/')
  400.       address command 'LhA a -q -e -r -Qo "'patch(lhafile,0)'" T:LhADir'port'/' '"'patch(lhasubdir||dirtomake,1)'"'
  401.       if rc>0 then
  402.          topline="Error while adding to archive."
  403.       else do
  404.          topline="Directory created."
  405.          addfile '"'dirtomake'" 0 1' now '"" ----RWED 0 1'
  406.          end
  407.       delete 'T:LhADir'port
  408.       delete 'T:LhADir.list'port
  409.       busy on
  410.       end
  411.    else do
  412.       if upper(right(dirtomake,4))=='.LHA' then  /* create new archive */
  413.          if open('emptyarchive',winpath||dirtomake,'w') then do
  414.             call writech('emptyarchive','0'x)
  415.             call close('emptyarchive')
  416.             topline="Empty archive created."
  417.             protect '"'winpath||dirtomake'" RWD'
  418.             addfile '"'dirtomake'" 1 -1' now '"" ----RW-D 0 1'
  419.             end
  420.          else
  421.             topline="Error creating archive."
  422.       else do  /* normal makedir */
  423.          restore
  424.          makedir '"'dirtomake'"'
  425.          end
  426.       end
  427.    return
  428.  
  429.  
  430. dogetsizes:
  431.  
  432.    if ~lhadir then
  433.       getsizes
  434.    return
  435.  
  436.  
  437. doversion:
  438.  
  439.    if entries=0 then
  440.       thisfile='REXX:LhADir.dopus'
  441.    toptext "Searching for version string..."
  442.    address command 'Version >T:Version.temp' thisfile 'FILE FULL'
  443.    call open('tempfile','T:Version.temp','r')
  444.    topline=readln('tempfile')
  445.    call close ('tempfile')
  446.    delete 'T:Version.temp'
  447.    return
  448.  
  449.  
  450. doundms:
  451.  
  452.    if entries=0|upper(right(selected,4))~=='.DMS' then
  453.       call quitit("No DMS file selected.")
  454.    drive.1='DF0:'
  455.    drive.0='RAD:'
  456.    status 26 set drive.1
  457.    status 27 set drive.0
  458.    toptext thisfile
  459.    request "Please insert disk and select"lf"destination drive for DMS file."
  460.    dest=result
  461.    busy on
  462.    checkabort
  463.    if result then
  464.       call quitit("Aborted...")
  465.  
  466.    if drive.dest='RAD:'&~showlist('h','RAD') then
  467.       address command 'Mount RAD:'  /* automatically mount RAD: */
  468.  
  469.    address command 'Run >T:ProcessNo <NIL: DMS <NIL: >PIPE:dmsout WRITE' thisfile 'TO' drive.dest 'NOTEXT'
  470.    call open('temp','T:ProcessNo','r')
  471.    process=readln('temp')
  472.    parse var process '[CLI ' process ']'
  473.    call close('temp')
  474.    delete 'T:ProcessNo'
  475.    busy on
  476.  
  477.    nomess=1
  478.    errors=''
  479.    buffer=''
  480.    call open('dmsout','PIPE:dmsout','r')
  481.    do until eof('dmsout')
  482.       buffer=buffer||readch('dmsout',25)
  483.       here=verify(buffer,'0a0d'x,'m')
  484.       if here>0 then do
  485.          line=left(buffer,here-1)
  486.          if nomess&left(line,7)='No Disk' then do
  487.             toptext "Insert disk in" drive.dest
  488.             nomess=0
  489.             end
  490.          if pos('Write-Protected',line)>0 then do
  491.             address command 'Break' process 'C'
  492.             topline="Disk in drive" drive.dest "is write protected."
  493.             beep
  494.             leave
  495.             end
  496.          parse var line ' ' line
  497.          buffer=substr(buffer,here+1)
  498.          if pos('ERROR',upper(line))>0 then do
  499.             errors=errors||lf||line
  500.             beep
  501.             busy on
  502.             end
  503.          if pos('unPacking',line)>0 then do
  504.             track=right(line,2)
  505.             toptext "Unpacking '"selected"'...  Track" track
  506.             checkabort
  507.             if result then do
  508.                address command 'Break' process 'C'
  509.                topline="Aborted..."
  510.                end
  511.             end
  512.          end
  513.       end
  514.    call close('dmsout')
  515.    if errors~=='' then do
  516.       toptext thisfile
  517.       notify "Error Report"||lf||errors
  518.       end
  519.    return
  520.  
  521.  
  522. docfx:
  523.  
  524.    if entries=0 then
  525.       call quitit
  526.    toptext "Examining file..."
  527.    address command 'CFX >T:CFX.temp BeQuiet' thisfile
  528.    call open('tempfile','T:CFX.temp','r')
  529.    topline=readln('tempfile')
  530.    call close ('tempfile')
  531.    delete 'T:CFX.temp'
  532.    return
  533.  
  534.  
  535. checklhadir:
  536.  
  537.    arg checkwin
  538.    status 13 checkwin  /* get window path */
  539.    winpath=result
  540.    test=upper(winpath)
  541.    cuthere=pos('.LHA/',test)
  542.    if cuthere=0 then
  543.       cuthere=pos('.LZH/',test)
  544.    if cuthere=0 then
  545.       cuthere=pos('.RUN/',test)
  546.    lhadir=cuthere>0
  547.    if lhadir then do
  548.       lhafile=left(winpath,cuthere+3)
  549.       lhasubdir=substr(winpath,cuthere+5)
  550.       end
  551.    return
  552.  
  553.  
  554. lhaextract:
  555.  
  556.    status 8 win  /* get number of dirs selected */
  557.    anydirs=result>0
  558.    mustmove=anydirs&s_lhasubdir~==''
  559.    if mustmove then
  560.       destpath=winpath'LhADir'port'/'
  561.    else
  562.       destpath=winpath
  563.  
  564.    call open('actionfile','T:actionfile'port,'w')
  565.    do i=1 to entries
  566.       if type.i>0 then
  567.          wild='/#?'
  568.       else
  569.          wild=''
  570.       call writeln('actionfile','"'patch(s_lhasubdir||name.i,1)||wild'"')
  571.       end
  572.    call close('actionfile')
  573.  
  574.    if anydirs then
  575.       lhacmd='x'
  576.    else
  577.       lhacmd='e -x2'
  578.    toptext "Extracting from archive..."
  579.    address command 'LhA' lhacmd '-q -a -C0 -Qo "'patch(s_lhafile,0)'" "'destpath'" @T:actionfile'port
  580.    problem=rc>0
  581.    if problem then
  582.       topline="Error while extracting from archive."
  583.    else do
  584.       topline="OK"
  585.       if notmove then
  586.          none
  587.       end
  588.  
  589.    if mustmove then do
  590.       do i=1 to entries
  591.          move '"'winpath'LhADir'port'/'s_lhasubdir||name.i'" "'winpath'"'
  592.          end
  593.       delete '"'winpath'LhADir'port'"'
  594.       end
  595.    delete 'T:actionfile'port
  596.    busy on
  597.    return
  598.  
  599.  
  600. lhaadd:
  601.  
  602.    mustcopy=upper(right(src,length(lhasubdir)))~==upper(lhasubdir)
  603.    if mustcopy then do  /* all files must be copied to T: before they can be added */
  604.       homedir='T:LhADir'port'/'
  605.       call createdirs
  606.       end
  607.    else
  608.       homedir=left(src,length(src)-length(lhasubdir))
  609.    call open('actionfile','T:actionfile'port,'w')
  610.    call writeln('actionfile','"'patch(homedir,0)'"')
  611.  
  612.    if s_lhadir then
  613.       call writeln('actionfile','#?')
  614.    else do
  615.       do i=1 to entries
  616.          call writeln('actionfile','"'patch(lhasubdir||name.i,0)'"')
  617.          if mustcopy then do
  618.             copy '"'src||name.i'" "T:LhADir'port'/'lhasubdir'"'
  619.             busy on
  620.             end
  621.          end
  622.       end
  623.    call close('actionfile')
  624.  
  625.    if pos('.LZH/',test)>0 then
  626.       method='-0'
  627.    else
  628.       method=''
  629.    toptext "Adding to archive..."
  630.    address command 'LhA r' method '-q -e -r -Qo "'patch(lhafile,0)'" @T:actionfile'port
  631.    problem=rc>0
  632.    if problem then
  633.       topline="Error while adding to archive."
  634.    else do
  635.       topline="OK"
  636.       if notmove then
  637.          none
  638.       end
  639.    delete 'T:actionfile'port
  640.    if mustcopy|s_lhadir then
  641.       delete 'T:LhADir'port
  642.    busy on
  643.    call swapactive
  644.    listlha=1
  645.    call showlhadir
  646.    call swapactive
  647.    return
  648.  
  649.  
  650. lhalist:
  651.  
  652.    address command 'LhA >T:LhADir.list'port 'vv -N -Qw -Qo "'lhafile'"'
  653.    if rc>0 then do
  654.       setwintitle '"<Directory not available>"'
  655.       call quitit("Error while listing archive.")
  656.       end
  657.    return
  658.  
  659.  
  660. getnextone:
  661.  
  662.    getnextselected
  663.    selected=result
  664.    if follow then
  665.       scrolltoshow '"'selected'"'
  666.    fileinfo '"'selected'"' '1c'x
  667.    parse var result '1c'x '1c'x '1c'x filetype '1c'x
  668.    return
  669.  
  670.  
  671. getall:
  672.  
  673.    status 6 win  /* get total number of entries */
  674.    tot=result
  675.    n=1
  676.    do i=1 to tot
  677.       getentry i
  678.       name.n=result
  679.       fileinfo '"'result'"' '1c'x
  680.       parse var result '1c'x '1c'x '1c'x type.n '1c'x sel '1c'x
  681.       if sel then
  682.          n=n+1
  683.       end
  684.    return
  685.  
  686.  
  687. createdirs:
  688.  
  689.    parse arg subdir
  690.    dirstocreate='T:LhADir'port'/'lhasubdir||subdir
  691.    here=0
  692.    do until here=0
  693.       here=pos('/',dirstocreate,here+1)
  694.       if here>0 then
  695.          makedir '"'left(dirstocreate,here-1)'"'
  696.       end
  697.    busy on
  698.    return
  699.  
  700.  
  701. swapactive:
  702.  
  703.    otherwindow
  704.    win=1-win
  705.    return
  706.  
  707.  
  708. showlhadir:
  709.  
  710.    status 13 win set '"'lhafile'/'lhasubdir'"'
  711.    toptext "Listing archive..."  /* toptext obscures error message */
  712.    cuthere=lastpos('/',lhafile)
  713.    if cuthere=0 then
  714.       cuthere=lastpos(':',lhafile)
  715.    setwintitle '"LhADir:' substr(lhafile,cuthere+1)'"'
  716.    call readlist
  717.    return
  718.  
  719.  
  720. readlist:
  721.  
  722.    if ~exists(lhafile) then
  723.       call quitit("Error, archive not found.")
  724.    if listlha|~exists('T:LhADir.list'port) then
  725.       call lhalist
  726.    else do
  727.       call open('tempfile','T:LhADir.list'port,'r')
  728.       nextline=readln('tempfile')
  729.       call close('tempfile')
  730.       parse var nextline 21 whicharc "':"
  731.       if upper(whicharc)~==upper(lhafile) then  /* it's another archive's list */
  732.          call lhalist
  733.       end
  734.    address command 'LhADirList T:LhADir.list'port '"'lhasubdir'"'
  735.    if rc>0 then
  736.       topline="Error while listing archive."
  737.    if ~open('tempfile','T:LhADir.list'port'@','r') then
  738.       call quitit("Error, LhADirList not properly installed.")
  739.    thisline=readln('tempfile')
  740.    do while thisline~=''
  741.       parse var thisline '"' name '" ' size ' ' type ' '  seconds ' ' atts ' ' comment
  742.       addfile '"'name'"' size type seconds '"'comment'"' atts '0 0'
  743.       thisline=readln('tempfile')
  744.       end
  745.    displaydir
  746.    call close('tempfile')
  747.    delete 'T:LhADir.list'port'@'
  748.    busy on
  749.    return
  750.  
  751.  
  752. patch:  /* patch filenames containing strange characters */
  753.  
  754.    parse arg patched,apostrophe
  755.    verstr='*#?|%()[]~'
  756.    if apostrophe then
  757.       verstr=verstr"'"
  758.    pos=1
  759.    do until here=0
  760.       here=verify(substr(patched,pos),verstr,'m')
  761.       if here>0 then do
  762.          pos=pos+here+1
  763.          patched=insert("'",patched,pos-3)
  764.          end
  765.       end
  766.    if left(patched,1)='@' then
  767.       patched='*'patched
  768.    return patched
  769.  
  770.  
  771. syntax:
  772.  
  773.    call quitit("Syntax Error" rc"," errortext(rc) "in line" sigl".")
  774.  
  775.  
  776. checkconfig:
  777.  
  778.    status 26
  779.    okaystring=result
  780.    status 27
  781.    cancelstring=result
  782.  
  783.    query dirflags
  784.    olddirflags=result
  785.    if olddirflags<0 then  /* bug in DOpus? */
  786.       olddirflags=256+olddirflags
  787.    if bittst(d2c(olddirflags),5) then do
  788.       request "The config setting 'Re-read changed buffers'"lf"must be switched off. Shall I do this for you?"
  789.       if ~result then do
  790.          remember  /* something to restore */
  791.          call quitit("Error, config setting 'Re-read changed buffers' must be switched off.")
  792.          end
  793.       modify dirflags olddirflags-32
  794.       end
  795.  
  796.    remember                /* remember user settings */
  797.    busy on
  798.    query updateflags
  799.    follow=bittst(d2c(result),1)        /* scroll window to follow operations? */
  800.    modify updateflags 0            /* no progress indicator */
  801.    query deleteflags
  802.    askdelete=bittst(d2c(result),0)    /* ask before deleting? */
  803.    modify deleteflags 8            /* don't ask when deleting internal */
  804.    modify replaceflags 1        /* don't ask when replacing internal */
  805.    modify iconflags 0            /* no icons please */
  806.    query font 2                /* text viewer font */
  807.    parse var result fontname '.font/' fontsize
  808.    return
  809.  
  810.  
  811. quitit:
  812.  
  813.    parse arg topline
  814.    status 26 set okaystring        /* restore okay and */
  815.    status 27 set cancelstring        /* cancel strings */
  816.    restore                /* restore user settings */
  817.    if topline~=="" then
  818.       toptext topline            /* display final message */
  819.    if pos("Error",topline)>0 then
  820.       beep                /* an error occurred */
  821.    busy off                /* busy mouse pointer off */
  822.    exit                    /* stop script here */
  823.